package top.kpromise.user.filter;

import org.springframework.stereotype.Component;

import javax.servlet.*;
import java.io.IOException;

@Component
public class TimeFilter implements Filter {

    @Override
    public void init(FilterConfig filterConfig) {
        System.out.println("timeFilter init !");
    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        System.out.println("timeFilter start");
        long start = System.currentTimeMillis();
        chain.doFilter(request,response);
        System.out.println("timeFilter耗时:"+(System.currentTimeMillis()-start));
        System.out.println("timeFilter stop");
    }

    @Override
    public void destroy() {
        System.out.println("timeFilter destroy!");
    }
}
